<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,member-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="css/pagination.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet"
	type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>优惠券管理</title>
</head>
<body>
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 运营中心 <span class="c-gray en">&gt;</span> 全城优惠 

		<a class="btn btn-primary radius r mr-10 mt-5"
				onclick="juan_add('添加全城优惠','<%=path%>/backstage/juan-quan-add-pre')"
				href="javascript:;">发放全城优惠</a>

		<a class="btn btn-success btn-refresh radius r mr-20"
			style="line-height:1.6em;margin-top:3px"
			onclick="javascript:location.replace(location.href);"
			href="javascript:location.replace(location.href);" title="刷新">刷新</a>
	</nav>
	<div class="pd-20">
		<!-- <div class="text-c">
			<form action="" method="post">
				范围： <input type="text" class="input-text" style="width:250px"
					placeholder="输入" id="key" value='' name="key">
				<button type="submit" class="btn btn-success radius" id="" name="">
					<i class="Hui-iconfont">&#xe665;</i> 查询
				</button>
			</form>
		</div> -->
		<!--
		<div class="cl pd-5 bg-1 bk-gray mt-20">
			<span class="l"></span>

		</div>
		-->
		<div class="mt-20" style="width:1500px;">
			<table
				class="table table-border table-bordered table-hover table-bg table-sort">
				<thead>
					<tr class="text-c">
						<th width="80">优惠劵编号</th>
						<th>名称</th>

						<th>分站</th>
						<th>指定商家</th>

						<th>上线时间</th>
						<th>开始时间</th>
						<th>截止时间</th>
	
						<th>已领取数量</th>
						<th>已使用数量</th>
						<th>发放数量</th>
					
						<th>创建者</th>
						<th>创建时间</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${juan_list}" var="juan">
						<tr class="text-c">
							<input type="hidden" id="id" name="id" value='${juan.c_id}' />
							<td>${juan.c_id}</td>
							<td>${juan.c_titles}</td>

							<td>${juan.name}</td>
							<td>${juan.c_sname }</td>

							<td>${juan.publish_time}</td>
							<td>${juan.c_stime}</td>
							<td>${juan.c_etime}</td>
							
							<td>${juan.used_count}</td>
							<td>${juan.receive_count}</td>
							<td>${juan.mileages}</td>
							
							<td>${juan.c_appuser}</td>
							<td>${juan.c_appdate}</td>
							<td>
							<c:choose>
									<c:when test="${juan.c_enable==0}"><span class="label label-warning radius" >已下线</span></c:when>
									<c:when test="${juan.c_enable==1}"><span class="label label-primary radius">已上线</span></c:when>
									<c:otherwise>
										<span class="label label-disabled  radius">未知</span>
									</c:otherwise>
							</c:choose>
							</td>
							<td class="td-manage"><a style="text-decoration:none"
								onClick="juan_quan_edit(this,'${juan.c_id}')" href="javascript:;" title="编辑">编辑</a>
								&nbsp;&nbsp;
								<a style="text-decoration:none"
								onClick="juan_quan_editstatus(this,'${juan.c_id}','1')"
								href="javascript:void(0);" title="上线">上线</a>
								&nbsp;&nbsp;
								<a style="text-decoration:none"
								onClick="juan_quan_editstatus(this,'${juan.c_id}','0')"
								href="javascript:void(0);" title="下线">下线</a>
								&nbsp;&nbsp;
								<a style="text-decoration:none"
								onClick="juan_view(this,'${juan.c_id}')"
								href="javascript:void(0);" title="详情">详情</a></td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
			<div id="Pagination" class="page-con"></div>
		</div>
	</div>
	<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="lib/layer/1.9.3/layer.js"></script>
	<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
	<script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript"
		src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="js/H-ui.js"></script>
	<script type="text/javascript" src="js/H-ui.admin.js"></script>
	<script type="text/javascript" src="js/jquery.pagination.js"></script>
	<script type="text/javascript">
		$(function() {
			initPager();
		});
		
		var showCount = ${pageInfo.showCount};
		var currentPage = ${pageInfo.currentPage-1};
		var totalResult = ${pageInfo.totalResult};
		function initPager(){
			$("#Pagination").pagination(totalResult, {
                callback: function(new_page_index, pagination_container){
                	var oldLocation = location.href;
                	var pa = "currentPage=" + (new_page_index+1);
            		var shoC = "showCount=" + showCount;
                	var index = oldLocation.lastIndexOf("?");
                	if (index == -1){
                		location.href = oldLocation + "?" + pa + "&" + shoC;
                	}else if (oldLocation.indexOf("currentPage") == -1){
                		location.href = oldLocation + "&" + pa;
                	}else if (oldLocation.indexOf("showCount") == -1){
                		location.href = oldLocation + "&" + shoC;
                	}else{
                		var temp = oldLocation.replace(/currentPage=\d+/, pa);
						var newLocation = temp.replace(/showCount=\d+/, shoC);
                		location.href = newLocation;
                	}
                	return false;
                },
                items_per_page:showCount, 
                load_first_page:false,
                prev_text:'上一页',
                next_text:'下一页',
                ellipse_text:'...',
                num_edge_entries:1,
                num_display_entries:5,
                current_page:currentPage,
            });
		}

		/*添加*/
		function juan_add(title, url) {
			var index = layer.open({
				type : 2,
				title : title,
				content : url
			});
			layer.full(index);
		}
		
		/*编辑*/
		function juan_quan_edit(obj,id,w,h){
			var edit_page = "<%=path%>/backstage/juan-quan-add-pre?id="+id;
			//layer_show("编辑",edit_page,w,h);
			var index = layer.open({
				type: 2,
				title: "编辑",
				content: edit_page
			});
			layer.full(index);
		}


		/*删除*/
		function juan_quan_editstatus(obj, id, status){
			layer.confirm('确认此操作？', {
				btn: ['确认','取消'], 
				shade: false
			},
			function(){
				$.ajax({
					type : "POST",
					url : "<%=path%>/backstage/juan-quan-editstatus",
					data : "id=" + id +"&enable=" + status,
					error : function() {
						layer.msg('操作失败', {icon:5,time:1000});
					},
					success : function(msg) {
						layer.msg('已操作 ' + msg.information, {icon:6,time:1000});
						$(obj).parents("body").find(".btn-refresh").click();
					}
				});
			},
			function(){
				layer.msg('未操作', {icon:5,time:1000});
			});	
		}

		/*查看*/
		function juan_view(obj,id,w,h){
			var edit_page = "<%=path%>/backstage/juan_quan-view?id="+id;
			layer_show("查看",edit_page,w,h);
		}

		/*删除*/
		function juan_delete(obj,id){
			layer.confirm('确认此操作？', {
				btn: ['确认','取消'], 
				shade: false
			},
			function(){
				$.ajax({
					type : "POST",
					url : "<%=path%>/backstage/juan-delete",
					data : "id=" + id,
					error : function() {
						layer.msg('操作失败', {icon:5,time:1000});
					},
					success : function(msg) {
						layer.msg('已删除 ' + msg.information, {icon:6,time:1000});
						$(obj).parents("body").find(".btn-refresh").click();
					}
				});
			},
			function(){
				layer.msg('未删除', {icon:5,time:1000});
			});	
		}
	
	</script>
</body>
</html>